#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
using namespace std;

int main()
{
    int a, b, c;
    scanf("%d %d", &a, &b);
    c = (a + b) % 7;
    if (c == 0)
        c = 7;
    printf("%d\n", c);
    return 0;
}